package com.yy.job.console.dto;

import java.util.Map;

import com.google.common.collect.Maps;
import com.yy.job.common.utils.PagingParam;

public class JobSearchParamDTO {

	private Integer pageSize;

	private Integer currentPage;

	private Integer startRow;
	
	private Map<String, Object> params = Maps.newHashMap();
	
	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getStartRow() {
		return startRow;
	}

	public void setStartRow(Integer startRow) {
		this.startRow = startRow;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

	public Integer calStartRow() {
		return currentPage <= 0 ? 0 : (currentPage-1) * pageSize;
	}
	
	public PagingParam buildPagingParam() {
		PagingParam pagingParam = new PagingParam();
		pagingParam.setPageSize(this.getPageSize());
		pagingParam.setCurrentPage(this.getCurrentPage());
		pagingParam.setStartRow(this.calStartRow());
		pagingParam.setParams(this.getParams());
		
		return pagingParam;
	}
}
